package io.oschina.binv.kapp

import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.support.v7.widget.RecyclerView
import android.widget.Button
import android.widget.TextView
import com.yalantis.ucrop.UCrop
import io.oschina.binv.kapp.fragment.FirstFragment
import io.oschina.binv.kapp.framework.BaseActivity
import io.oschina.binv.kapp.framework.ReuseActivity
import java.io.File

class MainActivity : BaseActivity() {

    val button3 by lazy {
        findViewById<Button>(R.id.button3)
    }
    val button4 by lazy {
        findViewById<Button>(R.id.button4)
    }

    override fun setContentView() {
        setContentView(R.layout.activity_main)
    }

    override fun initViewsAndLocalData(savedIntent: Intent): (outIntent: Intent) -> Unit {
        findViewById<TextView>(R.id.tv_1).setOnClickListener{
            _->
            val intent=Intent(this@MainActivity, ReuseActivity::class.java)
            intent.putExtra(ReuseActivity.FRAGMENT_NAME, FirstFragment::class.java.canonicalName)
            intent.putExtra(ReuseActivity.FRAGMENT_ARGS, Bundle().apply {
                putString(FirstFragment.TITLE,"第一个页面")
                putString(FirstFragment.PAYLOAD,"内容一")
            })
            startActivity(intent)
        }
        button3.setOnClickListener { _->
            //setResult(Activity.RESULT_OK, Intent().putExtra(UCrop.EXTRA_OUTPUT_URI, Uri.fromFile(File("/cmi/"))))
            onBackPressed()
        }
        button4.setOnClickListener { _->
            //setResult(Activity.RESULT_OK)
            finish()
        }
        return {}
    }

    override fun loadRemoteData() {

    }
}
